#   抛出  raise

# 自定义异常  继承于 Exception 或 BaseException

class AgeException(Exception):
    pass

e = AgeException('Age Error:  " Age less than six years old  ! "')

def to_study(age):
    if age>=6:
        print('You can go to studying')
    else:
        raise e

to_study(6)
try:
    to_study(3)
except AgeException as e:
    print(e)
# try:
#     to_study(3)
# except AgeException as e:
#     print(e)


print('---------------------->')


class AgeException(Exception):
    def __init__(self,age = 'Age Error! '):
        self.age = age

    def __str__(self):
        return self.age

e = AgeException()
def to_study(age):
    if age>=6:
        print('You can go to studying')
    else:
        raise e
# to_study(3)